/// <reference path="_variables.scss" />
/// <reference path="_functions.scss" />
/// <reference path="_mixins.scss" />

.btn-close {
  --btn-close-color: #{$btn-close-color};
  --btn-close-bg: #{ escape-svg($btn-close-bg) };
  --btn-close-opacity: #{$btn-close-opacity};
  --btn-close-hover-opacity: #{$btn-close-hover-opacity};
  --btn-close-focus-shadow: #{$btn-close-focus-shadow};
  --btn-close-focus-opacity: #{$btn-close-focus-opacity};
  --btn-close-disabled-opacity: #{$btn-close-disabled-opacity};
  --btn-close-white-filter: #{$btn-close-white-filter};

  box-sizing: content-box;
  width: $btn-close-width;
  height: $btn-close-height;
  padding: $btn-close-padding-y $btn-close-padding-x;
  color: var(--btn-close-color);
  background: transparent var(--btn-close-bg) center / $btn-close-width auto no-repeat; // include transparent for button elements
  border: 0; // for button elements
  @include border-radius();
  opacity: var(--btn-close-opacity);
  transition: opacity 0.1s, color 0.1s;

  &:hover {
    color: var(--btn-close-color);
    text-decoration: none;
    opacity: var(--btn-close-hover-opacity);
  }

  &:focus {
    outline: 0;
    box-shadow: var(--btn-close-focus-shadow);
    opacity: var(--btn-close-focus-opacity);
  }

  &:disabled,
  &.disabled {
    pointer-events: none;
    user-select: none;
    opacity: var(--btn-close-disabled-opacity);
  }
}

.close {
  @extend .btn-close;
}

.btn-close-white {
  filter: var(--btn-close-white-filter);
}

.xclose {
  float: right;
  @include font-size($close-font-size);
  font-weight: $close-font-weight;
  line-height: 1;
  color: $close-color;
  text-shadow: $close-text-shadow;
  opacity: .5;

  // Override <a>'s hover style
  &:hover {
    color: $close-color;
    text-decoration: none;
  }

  &:not(:disabled):not(.disabled) {
    @include hover-focus() {
      opacity: .75;
    }
  }
}

// Additional properties for button version
// iOS requires the button element instead of an anchor tag.
// If you want the anchor version, it requires `href="#"`.
// See https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile

// stylelint-disable-next-line selector-no-qualifying-type
button.xclose {
  padding: 0;
  background-color: transparent;
  border: 0;
}

// Future-proof disabling of clicks on `<a>` elements

// stylelint-disable-next-line selector-no-qualifying-type
a.xclose.disabled {
  pointer-events: none;
}
